import { defineStore } from "pinia";
import Pinia from "@/store";

export interface SearchResult {
  // SublibNo: string;
  [key: string]: any;
}

interface SearchState {
  results: SearchResult[];
}

export const useSearchStoreHook = defineStore("search", {
  state: (): SearchState => ({
    results: []
  }),
  getters: {
    // filteredResults(state: SearchState) {}
  },
  actions: {
    setResults(newResults: SearchResult[]) {
      this.results = newResults;
    },
    addResult(result: SearchResult) {
      this.results.push(result);
    }
  }
});

export function useSearchStore() {
  return useSearchStoreHook(Pinia);
}
